(function($) {
    var init={
    		"bFilter": true,//搜索框
    		"aoColumns" : [
                           {"data" : "cname"},
                           {"data" : "startAtToString"},
                           {"data" : "endAtToString"},
                           {"data" : "cost"},
                           {"data" : "pv"},
                           {"data" : "pc"},
                           {"data" : "clickRate"},
                           {"data" : "avgCost"},
                           {"data" : "avgCostView"},
                           {
                           	"targets": [9],
                               "data": "id",
                               "render": function(data, type, full) {
                                 return "<a href='/ads/adId/edit?id=" + data + "'>统计</a>";
                                 }
                              },
                       ],
             "sAjaxSource": "/campaigns/index",//这个是请求的地址
    }
    $(function(){
        $.extend(init,dataTableInit)
        $("#campaignsTable").dataTable(init)
    })
    
    //在表单外自定义全局搜索框
    $("#search").on( 'keyup click', function () {
    	  $("#campaignsTable").DataTable().search(
    		        $('#search').val()
    		    ).draw();
    } );
    
    $("#time").on('click',function(){
    	var time=$('#start').val()+","+ $('#end').val();
    	 $('#campaignsTable').DataTable().column( 0 ).search(
    			 time
 		    ).draw();
    });
})($);

(function($) {
    var init={
    		"bFilter": true,//搜索框
    		"aoColumns" : [
                           {"data" : "rptDateToString"},
                           { "data" : "pv",},
                           {"data" : "pc"},
                           {"data" : "clickRate"},
                           {"data" : "avgCost"},
                           {"data" : "avgCostView"},
                           {"data" : "cost"},
                       ],
             "sAjaxSource": "/reports/campaign",//这个是请求的地址
    }
    $(function(){
        $.extend(init,dataTableInit)
        $("#rptCampTable").dataTable(init)
    })
    
    //在表单外自定义全局搜索框
    $("#search").on( 'keyup click', function () {
    	  $("#rptCampTable").DataTable().search(
    		        $('#search').val()
    		    ).draw();
    } );

    $("#time").on('click',function(){
    	var time=$('#start').val()+","+ $('#end').val();
    	 $('#rptCampTable').DataTable().column( 0 ).search(
    			 time
 		    ).draw();
    });
})($);